package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.RemoteWebElement;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpContractsQuoterPageUtil extends SeleniumPageUtil {
	public final static By STQ_LINK_QUOTER = By.id("btnTab1");
	public final static By STQ_LINK_QUOTER_NEW = By.id("btnQuoteMenu_New");
	public final static By STQ_LINK_QUOTER_SEARCH = By.id("btnQuoteMenu_Search");
	public final static By STQ_LINK_QUOTER_LISTALL = By.id("btnQuoteMenu_ListAll");
	public final static By STQ_LINK_QUOTER_PROCESS_NEW = By.id("btnQuoteMenu_InProcessNew");
	public final static By STQ_LINK_QUOTER_PROCESS_CHANGES = By.id("btnQuoteMenu_InProcessChanges");
	public final static By STQ_LINK_QUOTER_PROCESS_RENEWAL = By.id("btnQuoteMenu_InProcessRenewals");
	public final static By STQ_LINK_QUOTER_COMPLETED = By.id("btnQuoteMenu_Completed");
	public final static By STQ_LINK_QUOTER_EXPORT_MAS = By.id("btnQuoteMenu_ExportsToMAS");
	public final static By STQ_LINK_QUOTER_WAIT_EXPORT = By.id("btnQuoteMenu_WaitingExport");
	public final static By STQ_LINK_ITEM = By.id("btnTab2");
	public final static By STQ_LINK_ITEM_NEW = By.id("btnItemMenu_New");
	public final static By STQ_LINK_ITEM_SEARCH = By.id("btnItemMenu_Search");
	public final static By STQ_LINK_ITEM_LISTQUO = By.id("btnItemMenu_ListQuotable");
	public final static By STQ_LINK_ITEM_LISTALL = By.id("btnItemMenu_ListAll");
	public final static By STQ_LINK_DASH = By.id("btnTab3");
	public final static By STQ_LINK_DASH_MYBOARD = By.xpath("//*[@id='btnDashboardMenu_MyDashboard']/b");
	public final static By STQ_LINK_DASH_MYAPP = By.id("btnDashboardMenu_MyApprovals");
	public final static By STQ_LINK_DASH_OVERVIEW = By.id("btnDashboardMenu_OverviewDashboard");
	public final static By STQ_LINK_DASH_OVERVIEWAPP = By.id("btnDashboardMenu_OverviewApproval");
	public final static By STQ_LINK_DASH_BOARD = By.id("btnDashboardMenu_Dashboard");
	public final static By STQ_LINK_DASH_ITEMNOTADD = By.id("btnDashboardMenu_ItemNotAdded");
	public final static By STQ_LINK_DASH_ITEMNOTADD_ES = By.id("btnDashboardMenu_ItemNotAdded_Escalated");
	public final static By STQ_LINK_DASH_EXPRESS = By.id("btnDashboardMenu_ExpressChanges");
	public final static By STQ_LINK_DASH_SUB = By.id("btnDashboardMenu_Subcontracting");
	public final static By STQ_LINK_REV_STATUS = By.id("btnTab4");
	public final static By STQ_TD_NEW_QUOTES = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[1]/td/b");
	public final static By STQ_LINK_DATA_ENTRY = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[2]/td/a");
	public final static By STQ_LINK_BUDGE = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[3]/td/a");
	public final static By STQ_LINK_DRAFT = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[4]/td/a");
	public final static By STQ_LINK_CUSTOMER = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[5]/td/a");
	public final static By STQ_LINK_CLOSED = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[6]/td/a");
	public final static By STQ_LINK_WON_FROM = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[7]/td/a");
	public final static By STQ_LINK_WON_IMPORT = By.xpath("//*[@id='lblStatusCodes']/table[1]/tbody/tr[8]/td/a");
	public final static By STQ_TD_CHANGE_REQUEST = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[1]/td/b");
	public final static By STQ_LINK_CSR_REVIEW = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[2]/td/a");
	public final static By STQ_LINK_SMS_PARTS = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[3]/td/a");
	public final static By STQ_LINK_SMS_SUB = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[4]/td/a");
	public final static By STQ_LINK_SMS_PRICING = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[5]/td/a");
	public final static By STQ_LINK_SMS_CON = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[6]/td/a");
	public final static By STQ_LINK_CUSTOMER_REVIEW = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[7]/td/a");
	public final static By STQ_LINK_CHANGE_CLOSED = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[8]/td/a");
	public final static By STQ_LINK_CHANGE_WON_IMPORT = By.xpath("//*[@id='lblStatusCodes']/table[2]/tbody/tr[9]/td/a");
	public final static By STQ_TD_RENEWALS = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[1]/td/b");
	public final static By STQ_LINK_R_CSR_REVIEW = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[2]/td/a");
	public final static By STQ_LINK_R_SMS_PARTS = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[3]/td/a");
	public final static By STQ_LINK_R_SMS_SUB = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[4]/td/a");
	public final static By STQ_LINK_R_SMS_PRICING = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[5]/td/a");
	public final static By STQ_LINK_R_SMS_CON = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[6]/td/a");
	public final static By STQ_LINK_R_CUSTOMER_REVIEW = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[7]/td/a");
	public final static By STQ_LINK_R_CLOSED = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[8]/td/a");
	public final static By STQ_LINK_R_WON_IMPORT = By.xpath("//*[@id='lblStatusCodes']/table[3]/tbody/tr[9]/td/a");
	public final static By STQ_SPAN_PREFER = By.id("Menu_Chrome1_lblMenu");
	public final static By STQ_SPAN_QUICK_LINK = By.id("Menu_Chrome1_lblQuickLinks");
	public final static By STQ_LINK_QUICK_CSR_SALE = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/a[1]");
	public final static By STQ_LINK_QUICK_CUSTOMER = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/a[2]");
	public final static By STQ_LINK_QUICK_USERS = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/a[3]");
	public final static By STQ_LINK_QUICK_SLA = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/a[4]");
	public final static By STQ_LINK_QUICK_PROBLEM_DEFINITIONS = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/a[5]");
	public final static By STQ_LINK_QUICK_LOOKUP = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/a[6]");
	public final static By STQ_LINK_QUICK_ITEMS = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/b[1]/a");
	public final static By STQ_LINK_QUICK_QUOTES = By.xpath("//*[@id='Menu_Chrome1_lblQuickLinksList']/b[2]/a");
	public final static By STQ_LINK_LOG_OUT = By.id("Menu_Chrome1_btnLogoutChrome");
	public final static By STQ_DIV_RESULT_PAGE = By.xpath("//*[@id='Quoter_QuoteList1_lblPaging']/div");
	public final static By STQ_HEARD_TITLE = By.xpath("//*[@id='Quoter_QuoteList1_pnlPage']/table/tbody/tr/td[4]");
	

	public static void enter(){
		SpHomePageUtil.enter();
		SpHomePageUtil.enterContractsQuoter();
		waitForPageToLoad();
	}

	private static void waitForPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				STQ_LINK_QUOTER,STQ_LINK_ITEM,STQ_LINK_DASH,STQ_LINK_REV_STATUS
		});
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(STQ_LINK_QUOTER));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(STQ_LINK_ITEM));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(STQ_LINK_DASH));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(STQ_LINK_REV_STATUS));
	}
	public static void displayHidenMenu(By by){
		try {
			RemoteWebElement element = (RemoteWebElement)SeleniumUtil.getCachedElement(by);
			WebDriver driver = element.getWrappedDriver(); 
			Actions action = new Actions(driver);
			action.moveToElement(element);
			action.perform();
		} catch (Exception e) {
			SeleniumUtil.getScreenShot(e);
		}
	}
	public static void displayHidenMenus(By[] bys){
		if (bys != null && bys.length > 0 ) {
			for (By by : bys) {
				displayHidenMenu(by);
			}
		}
	}
}
